﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;

namespace MangaEplision.MangaView
{
    /// <summary>
    /// Interaction logic for MangaListItem.xaml
    /// </summary>
    public partial class MangaListItem : UserControl
    {
        private TabControl tab = null;
        private Manga ma = null;
        public MangaListItem(Manga mag,ref TabControl tc,bool getimg = true)
        {
            InitializeComponent();
            tab = tc;
            ma = mag;
            title.Content = mag.MangaName;
            textBlock1.Text = mag.Description;
            if (getimg == true)
            {
                image1.Source = mag.BookImage;
                image1.MouseEnter += new MouseEventHandler(image1_MouseEnter);
                image1.MouseLeave += new MouseEventHandler(image1_MouseLeave);
                p = new Popup();
                p.PopupAnimation = PopupAnimation.Fade;
                p.Child = new Image() { Source = mag.BookImage, Height = 400, Width = 400 };

                p.AllowsTransparency = true;
            }
        }
        Popup p = null;
        void image1_MouseLeave(object sender, MouseEventArgs e)
        {
            p.IsOpen = false;
        }

        void image1_MouseEnter(object sender, MouseEventArgs e)
        {
            p.PlacementTarget = title;
            p.IsOpen = true;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MangaInfoTab mft = new MangaInfoTab(ma);
            tab.Items.Add(mft);
            tab.SelectedItem = mft;
        }
    }
}
